# Contributor: Thomas Kienlen <kommander@laposte.net>
# Contributor: Maxim Karasev <begs@disroot.org>
# Maintainer: Thomas Kienlen <kommander@laposte.net>
pkgname=freeciv
pkgver=3.1.1
pkgrel=0
pkgdesc="Free and Open Source empire-building strategy game (meta package)"
url="http://www.freeciv.org"
arch="all"
license="GPL-2.0-or-later"
depends="
	$pkgname-server
	$pkgname-client-gtk3
	"
_common_makedepends="
	bash
	curl-dev
	gettext-dev
	gzip
	readline-dev
	sdl2_mixer-dev
	"
_gtk3_client_makedepends="
	at-spi2-core-dev
	gdk-pixbuf-dev
	glib-dev
	gtk+3.0-dev
	pango-dev
	"
_gtk4_client_makedepends="
	at-spi2-core-dev
	gdk-pixbuf-dev
	glib-dev
	gtk4.0-dev
	pango-dev
	"
_qt_client_makedepends="
	qt6-qtbase-dev
	"
_sdl2_client_makedepends="
	sdl2-dev
	sdl2_gfx-dev
	sdl2_image-dev
	sdl2_ttf-dev
	"
_server_makedepends="
	sqlite-dev
	"
makedepends="
	$_common_makedepends
	$_gtk3_client_makedepends
	$_gtk4_client_makedepends
	$_qt_client_makedepends
	$_sdl2_client_makedepends
	$_server_makedepends
	"
source="https://files.freeciv.org/stable/freeciv-$pkgver.tar.xz"
subpackages="
	$pkgname-doc
	$pkgname-lang
	$pkgname-data::noarch
	$pkgname-server
	$pkgname-common-client:common_client:noarch
	$pkgname-client-gtk3:client_gtk3
	$pkgname-client-gtk4:client_gtk4
	$pkgname-client-qt:client_qt
	$pkgname-client-sdl2:client_sdl2
	lib$pkgname-static:lib_static
	"

build() {
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--enable-client=gtk3.22,gtk4,qt,sdl2 \
		--enable-debug=no \
		--enable-fcmp=gtk3,qt,cli \
		--enable-fcdb=sqlite3 \
		--enable-ipv6=yes \
		--with-readline \
		--build=$CBUILD --host=$CHOST

	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

# subpackages

doc() {
	pkgdesc="Free and Open Source empire-building strategy game (documentation)"

	default_doc
}

data() {
	pkgdesc="Free and Open Source empire-building strategy game (data files for client and server)"
	depends=""

	amove usr/share/freeciv
}

lib_static() {
	pkgdesc="Free and Open Source empire-building strategy game (static libs for ai modules)"
	depends=""

	amove usr/lib/libfreeciv-srv.a
	amove usr/lib/libfreeciv.a
}

common_client() {
	pkgdesc="Free and Open Source empire-building strategy game (common files for every clients)"
	depends=""

	amove usr/share/icons/hicolor/128x128/apps/freeciv-client.png
	amove usr/share/icons/hicolor/16x16/apps/freeciv-client.png
	amove usr/share/icons/hicolor/32x32/apps/freeciv-client.png
	amove usr/share/icons/hicolor/48x48/apps/freeciv-client.png
	amove usr/share/icons/hicolor/64x64/apps/freeciv-client.png
	amove usr/share/icons/hicolor/128x128/apps/freeciv-modpack.png
	amove usr/share/icons/hicolor/16x16/apps/freeciv-modpack.png
	amove usr/share/icons/hicolor/32x32/apps/freeciv-modpack.png
	amove usr/share/icons/hicolor/48x48/apps/freeciv-modpack.png
	amove usr/share/icons/hicolor/64x64/apps/freeciv-modpack.png

	amove usr/share/pixmaps/freeciv-client.png
}

client_gtk3() {
	pkgdesc="Free and Open Source empire-building strategy game (gtk3.22 client)"
	depends="$pkgname-data $pkgname-common-client $pkgname-server"
	provides="$pkgname-client"
	provider_priority="1"

	amove usr/bin/freeciv-gtk3.22
	amove usr/bin/freeciv-manual
	amove usr/bin/freeciv-mp-gtk3
	amove usr/share/applications/org.freeciv.gtk322.desktop
	amove usr/share/applications/org.freeciv.gtk3.mp.desktop
	amove usr/share/metainfo/org.freeciv.gtk322.metainfo.xml
	amove usr/share/metainfo/org.freeciv.gtk3.mp.metainfo.xml
}

client_gtk4() {
	pkgdesc="Free and Open Source empire-building strategy game (gtk4 client)"
	depends="$pkgname-data $pkgname-common-client $pkgname-server"
	provides="$pkgname-client"
	provider_priority="1"

	amove usr/bin/freeciv-gtk4
	amove usr/share/applications/org.freeciv.gtk4.desktop
	amove usr/share/metainfo/org.freeciv.gtk4.metainfo.xml
}

client_qt() {
	pkgdesc="Free and Open Source empire-building strategy game (qt client)"
	depends="$pkgname-data $pkgname-common-client $pkgname-server"
	provides="$pkgname-client"
	provider_priority="0"

	amove usr/bin/freeciv-qt
	amove usr/bin/freeciv-mp-qt
	amove usr/bin/freeciv-ruledit
	amove usr/bin/freeciv-ruleup
	amove usr/share/applications/org.freeciv.qt.mp.desktop
	amove usr/share/applications/org.freeciv.qt.desktop
	amove usr/share/applications/org.freeciv.ruledit.desktop
	amove usr/share/metainfo/org.freeciv.qt.mp.metainfo.xml
	amove usr/share/metainfo/org.freeciv.qt.metainfo.xml
	amove usr/share/metainfo/org.freeciv.ruledit.metainfo.xml
	amove usr/share/pixmaps/freeciv-modpack.png
	amove usr/share/pixmaps/freeciv-ruledit.png
	amove usr/share/icons/hicolor/128x128/apps/freeciv-ruledit.png
	amove usr/share/icons/hicolor/16x16/apps/freeciv-ruledit.png
	amove usr/share/icons/hicolor/32x32/apps/freeciv-ruledit.png
	amove usr/share/icons/hicolor/48x48/apps/freeciv-ruledit.png
	amove usr/share/icons/hicolor/64x64/apps/freeciv-ruledit.png
}

client_sdl2() {
	pkgdesc="Free and Open Source empire-building strategy game (sdl2 client)"
	depends="$pkgname-data $pkgname-common-client $pkgname-server"
	provides="$pkgname-client"
	provider_priority="0"

	amove usr/bin/freeciv-sdl2
	amove usr/share/applications/org.freeciv.sdl2.desktop
	amove usr/share/metainfo/org.freeciv.sdl2.metainfo.xml
}

server() {
	pkgdesc="Free and Open Source empire-building strategy game (server)"
	depends="$pkgname-data"

	amove etc/freeciv

	amove usr/bin/freeciv-server
	amove usr/bin/freeciv-mp-cli
	amove usr/share/applications/org.freeciv.server.desktop
	amove usr/share/metainfo/org.freeciv.server.metainfo.xml
	amove usr/share/icons/hicolor/128x128/apps/freeciv-server.png
	amove usr/share/icons/hicolor/16x16/apps/freeciv-server.png
	amove usr/share/icons/hicolor/32x32/apps/freeciv-server.png
	amove usr/share/icons/hicolor/48x48/apps/freeciv-server.png
	amove usr/share/icons/hicolor/64x64/apps/freeciv-server.png
}

sha512sums="
4ee39408aa843f2e63e9059a55c67b4374e4daddfc903519be611c9e026aea3a2755f80d18dd2179459700f18b59d21ada585e77dfe24769bf3f9c466654fe68  freeciv-3.1.1.tar.xz
"
